home *** CD-ROM | disk | FTP | other *** search
/ BBS Toolkit / BBS Toolkit.iso / windows / mrun211.zip / MRUN211.WAS < prev    next >
Text File  |  1993-05-01  |  34KB  |  1,042 lines

  1. ;MailRun v2.11:  Automated BBS Communications
  2. ;1992-1993 Gerald P. Sully, all rights reserved.
  3.  
  4.  
  5. #comment
  6. **************************************************************************
  7. **************************************************************************
  8. * The source code for MailRun is contained in 9 separate files: 
  9. * MRUN211.WAS (this file), MRUN211.H (a header file), and files 
  10. * named MRUN211?.WAS, where ? is a letter A through G.  MailRun
  11. * also requires the file MRUNICON.DLL in order to display the 
  12. * tool bar.
  13. * MRUN211.WAS is the script from which the other script files
  14. * are run.  It performs a brief initialization to find the
  15. * location of its support files, then chains to MRUN211A.WAS,
  16. * which is the principle engine of MailRun.  It will also 
  17. * perform an install routine if it finds that there is no
  18. * current MAILRUN.INI file.
  19. * The key files of MailRun are the *.MRN files.  These
  20. * store configuration information and control what tasks
  21. * will be performed on each BBS.  The user interface is
  22. * designed to provide a convenient way to edit these files
  23. * and display their contents.  The files are standard INI
  24. * files, and so may also be edited by hand.  The comm engine,
  25. * contained in MRUN211G.WAS, reads the currently loaded *.MRN
  26. * file, calls each BBS and executes each pending task.
  27. **************************************************************************
  28. **************************************************************************
  29. #endcomment
  30.  
  31.  
  32. #define IniFile 0
  33.  
  34. string MailRunIni, MailRunList, MailRunTrunc, MailRun, OldIni
  35. string MailRunDir, MailDir, ReplyDir, DownloadDir, UploadDir, TempDir
  36. string DialAttempts, DialTimeout, DialPause, IdleTimeout, SavePackets
  37. string Archiver, QWKReader, LogViewer
  38. integer LogRun, AppendLog, AnsiInLog, NewfileFilter, HelpPage
  39. float Version
  40.  
  41.  
  42. #comment
  43. *********************************************************************
  44. * MAIN()
  45. * Calls makefullname(), checkdir(), makeini(), gettempdir(),
  46. * delspec(), changesettings(), movedir(), updatemrn()
  47. * Executes MRUN211A.WAX
  48. * Checks for existence of MAILRUN.INI file, then chains
  49. * to the main body of the script.
  50. *********************************************************************
  51. #endcomment
  52.  
  53. proc main
  54. string MRunMain, temp, MailRunHelp
  55.     MailRunHelp = makefullname($PWTASKPATH, "mailrun.hlp")
  56.     if isfile MailRunHelp
  57.         set aspect helpfile "mailrun.hlp"
  58.     endif
  59.  
  60.    ;Create the temporary directory
  61.    gettempdir()
  62.    if !(checkdir(TempDir, ""))
  63.       halt
  64.    endif
  65.    
  66.    MailRunIni = makefullname($WINPATH, "MAILRUN.INI")
  67.    profilerd MailRunIni "MailRun" "Version" temp
  68.    atof temp Version
  69.    if Version != 2.11
  70.       ;if there is no .INI file for version 2.11, run install procedure
  71.         fetch aspect scriptpath temp
  72.        temp = makefullname(temp, "mailrun.hlp")
  73.        if not strcmpi MailRunHelp temp
  74.            copyfile temp MailRunHelp
  75.            delfile temp
  76.         endif
  77.         set aspect helpfile "mailrun.hlp"
  78.       makeini()
  79.       changesettings()
  80.       movedir()
  81.       if Version != 2.10
  82.           updatemrn()
  83.        endif
  84.         delfile OldIni
  85.       statmsg "Installation complete!"
  86.    endif
  87.  
  88.    ;Make sure the Temp directory is empty
  89.    delspec(TempDir, "*.*")
  90.    profilerd MailRunIni "MailRun" "MailRunDir" MailRunDir
  91.    MRunMain = makefullname(MailRunDir, "MRUN211A")
  92.    execute MRunMain
  93. endproc
  94.  
  95.  
  96. #comment
  97. *********************************************************************
  98. * DELSPEC()
  99. * Called by main()
  100. * Calls makefullname()
  101. * Deletes specified filespec from specified directory.
  102. *********************************************************************
  103. #endcomment
  104.  
  105. proc delspec
  106. strparm dirname, spec
  107. string filename, filespec
  108.    FileSpec = makefullname(dirname, spec)
  109.    findfirst FileSpec
  110.    while FOUND
  111.       FileName = makefullname(dirname, $FILENAME)
  112.       delfile FileName
  113.       findnext
  114.    endwhile
  115. endproc
  116.  
  117.  
  118. #comment
  119. *********************************************************************
  120. * MAKEINI()
  121. * Called by main()
  122. * Calls welcomebox(), getbbstypes()
  123. * Creates the MAILRUN.INI file and sets default values.
  124. *********************************************************************
  125. #endcomment
  126.  
  127. proc makeini
  128. string StateDLPath, StateULPath, AspectDir, temp, MailRunBak
  129. integer dialogstatus
  130. integer StateWaitCnct, StateCallPause, StateMaxDial
  131.    welcomebox()
  132.    ;Check whether user wishes to continue
  133.    while 1
  134.        dialogstatus = $DIALOG
  135.       switch dialogstatus
  136.           case 1
  137.               ;user chose Cancel
  138.               halt
  139.           endcase
  140.           case 10
  141.               ;user chose OK
  142.               exitwhile
  143.           endcase
  144.       endswitch
  145.    endwhile
  146.  
  147.     ;Save the old MAILRUN.INI file if it exists
  148.  
  149.     if isfile MailRunIni
  150.         OldIni = makefullname(TempDir, "oldini.tmp")
  151.         copyfile MailRunIni OldIni
  152.         MailRunBak = makefullname($WINPATH, "MAILRUN.BAK")
  153.         if isfile MailRunBak
  154.             delfile MailRunBak
  155.         endif
  156.         rename MailRunIni MailRunBak
  157.     endif        
  158.  
  159.    ;Create the file MAILRUN.INI
  160.  
  161.    fopen IniFile MailRunIni CREATE TEXT
  162.    if FAILURE
  163.       errormsg "Unable to create MAILRUN.INI;`r`nscript aborted...."
  164.       halt
  165.    endif 
  166.    fputs IniFile "[MailRun]"
  167.    fputs IniFile "Version=2.11"
  168.    fputs IniFile "MailRun="
  169.    fputs IniFile "MailRunDir="
  170.    fputs IniFile "MailDir="
  171.    fputs IniFile "ReplyDir="
  172.    fputs IniFile "DownloadDir="
  173.    fputs IniFile "UploadDir="
  174.    fputs IniFile "DialAttempts="
  175.    fputs IniFile "DialTimeout="
  176.    fputs IniFile "DialPause="
  177.    fputs IniFile "IdleTimeout="
  178.    fputs IniFile "SavePackets="
  179.    fputs IniFile "LogRun="
  180.    fputs IniFile "AppendLog="
  181.    fputs IniFile "AnsiInLog="
  182.    fputs IniFile "NewfileFilter="
  183.    fputs IniFile "Archiver="
  184.    fputs IniFile "QWKReader="
  185.    fputs IniFile "LogViewer="
  186.    fputs IniFile "DLSortField=0"
  187.    fputs IniFile "ULSortField=0"
  188.    fputs IniFile "DLPurgeLimit=0"
  189.    fputs IniFile "ExecTime=HH:MM:SS"
  190.    fputs IniFile "AutoRun=0"
  191.    fputs IniFile "GoWait=1"
  192.    fputs IniFile "PostRun=1"
  193.    fputs IniFile "RingInterrupt=1"
  194.    fputs IniFile ""
  195.    fputs IniFile "[BBSTypes]"
  196.    fputs IniFile "BBSType_1=PCBoard 14.5"
  197.    fputs IniFile "BBSType_2=PCBoard 15.0"
  198.    fputs IniFile "BBSType_3=WildCat! 3.6"
  199.    fputs IniFile "BBSType_4=Auntie"
  200.    fputs IniFile "BBSType_5=RBBS"
  201.    fputs IniFile ""
  202.    fputs IniFile "[MailDoors]"
  203.    fputs IniFile "MailDoor_1=QMail"
  204.    fputs IniFile "MailDoor_2=MarkMail"
  205.    fputs IniFile "MailDoor_3=Cam-Mail"
  206.    fputs IniFile "MailDoor_4=RoseMail"
  207.    fputs IniFile "MailDoor_5=TomCat"
  208.    fputs IniFile "MailDoor_6=Auntie Mail"
  209.    fputs IniFile "MailDoor_7=KingMail"
  210.    fputs IniFile "MailDoor_8=Mail Manager"
  211.    fputs IniFile ""
  212.    fputs IniFile "[DEFAULT]"
  213.    fputs IniFile "BBSName="
  214.    fputs IniFile "BBSType=PCBoard 14.5"
  215.    fputs IniFile "MailDoorType=KingMail"
  216.    fputs IniFile "Number_1="
  217.    fputs IniFile "Number_2="
  218.    fputs IniFile "Number_3="
  219.    fputs IniFile "UserName="
  220.    fputs IniFile "PWord="
  221.    fputs IniFile "UserResp1="
  222.    fputs IniFile "UserResp2="
  223.    fputs IniFile "XferProt=ZModem"
  224.    fputs IniFile "MailXferProt=ZModem"
  225.    fputs IniFile "QWKArchiver=pkunzip.exe"
  226.    fputs IniFile "LangNumber="
  227.    fputs IniFile "GraphicsOn=1"
  228.    fputs IniFile "LangPrompt=Language"
  229.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  230.    fputs IniFile "NamePrompt=first name"
  231.    fputs IniFile "PWordPrompt=Password"
  232.    fputs IniFile "UserPrompt1="
  233.    fputs IniFile "UserPrompt2="
  234.    fputs IniFile "ScanPrompt=Last Read"
  235.    fputs IniFile "ViewPrompt=View"
  236.    fputs IniFile "MorePrompt=More?"
  237.    fputs IniFile "FilePrompt="
  238.    fputs IniFile "ContinuePrompt=Continue"
  239.    fputs IniFile "CommandPrompt=Command?"
  240.    fputs IniFile "DLPrompt=Aborts Transfer"
  241.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  242.    fputs IniFile "ULPrompt=Aborts Transfer"
  243.    fputs IniFile "ULDescPrompt=? ("
  244.    fputs IniFile "MsgMenuPrompt="
  245.    fputs IniFile "MailDoor=KM"
  246.    fputs IniFile "MailPrompt=KingMail Command"
  247.    fputs IniFile "ReceiveQWKPrompt=When Done"
  248.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  249.    fputs IniFile "MailULPrompt=Aborts Transfer"
  250.    fputs IniFile ""
  251.    fputs IniFile "[PCBoard 14.5]"
  252.    fputs IniFile "GraphicsOn=1"
  253.    fputs IniFile "MailDoorType=KingMail"
  254.    fputs IniFile "LangPrompt=Language"
  255.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  256.    fputs IniFile "NamePrompt=first name"
  257.    fputs IniFile "PWordPrompt=Password"
  258.    fputs IniFile "ScanPrompt=Last Read"
  259.    fputs IniFile "ViewPrompt=View"
  260.    fputs IniFile "MorePrompt=More?"
  261.    fputs IniFile "ContinuePrompt=Continue"
  262.    fputs IniFile "CommandPrompt=Command?"
  263.    fputs IniFile "DLPrompt=Aborts Transfer"
  264.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  265.    fputs IniFile "ULPrompt=Aborts Transfer"
  266.    fputs IniFile "ULDescPrompt=? ("
  267.    fputs IniFile ""
  268.    fputs IniFile "[PCBoard 15.0]"
  269.    fputs IniFile "GraphicsOn=1"
  270.    fputs IniFile "MailDoorType=KingMail"
  271.    fputs IniFile "UserResp1=n"
  272.    fputs IniFile "UserPrompt1=Personal Mail"
  273.    fputs IniFile "LangPrompt=Language"
  274.    fputs IniFile "GraphicsPrompt=graphics (Enter)"
  275.    fputs IniFile "NamePrompt=first name"
  276.    fputs IniFile "PWordPrompt=Password"
  277.    fputs IniFile "ScanPrompt=Last Read"
  278.    fputs IniFile "ViewPrompt=View"
  279.    fputs IniFile "MorePrompt=More?"
  280.    fputs IniFile "ContinuePrompt=Continue"
  281.    fputs IniFile "CommandPrompt=Command?"
  282.    fputs IniFile "DLPrompt=Aborts Transfer"
  283.    fputs IniFile "DLUnavPrompt=(Enter)=none"
  284.    fputs IniFile "ULPrompt=Aborts Transfer"
  285.    fputs IniFile "ULDescPrompt=? ("
  286.    fputs IniFile ""
  287.    fputs IniFile "[WildCat! 3.6]"
  288.    fputs IniFile "MailDoorType=TomCat"
  289.    fputs IniFile "CallingFrom=City"
  290.    fputs IniFile "UserResp1=Birth Date"
  291.    fputs IniFile "UserResp2=Telephone"
  292.    fputs IniFile "GraphicsOn=0"
  293.    fputs IniFile "NamePrompt=first name"
  294.    fputs IniFile "PWordPrompt=Password"
  295.    fputs IniFile "UserPrompt1=Birth Date"
  296.    fputs IniFile "UserPrompt2=phone"
  297.    fputs IniFile "ScanPrompt=Last Read"
  298.    fputs IniFile "ViewPrompt=View"
  299.    fputs IniFile "MorePrompt=[S]top"
  300.    fputs IniFile "FilePrompt=FILE MENU"
  301.    fputs IniFile "ContinuePrompt=ontinue"
  302.    fputs IniFile "CommandPrompt=MAIN MENU"
  303.    fputs IniFile "DLPrompt=Please begin"
  304.    fputs IniFile "DLUnavPrompt=file # 1"
  305.    fputs IniFile "ULPrompt=Please begin"
  306.    fputs IniFile "ULDescPrompt=Description?"
  307.    fputs IniFile ""
  308.    fputs IniFile "[Auntie]"
  309.    fputs IniFile "GraphicsOn=0"
  310.     fputs IniFile "UserResp1=^C"
  311.     fputs IniFile "UserResp2=3"
  312.    fputs IniFile "MailDoorType=Auntie Mail"
  313.    fputs IniFile "NamePrompt=first name"
  314.    fputs IniFile "PWordPrompt=Password"
  315.     fputs IniFile "UserPrompt1=select the one"
  316.     fputs IniFile "UserPrompt2=Choice (1, 2 or 3)"
  317.    fputs IniFile "ViewPrompt=Bulletin:"
  318.    fputs IniFile "FilePrompt=Files Area"
  319.    fputs IniFile "ContinuePrompt=Continue"
  320.    fputs IniFile "CommandPrompt=Main Area"
  321.    fputs IniFile "DLPrompt=Ctrl+X"
  322.    fputs IniFile "DLUnavPrompt=Enter date"
  323.    fputs IniFile "ULPrompt=Ctrl+X"
  324.    fputs IniFile "ULDescPrompt=1 ?"
  325.    fputs IniFile ""
  326.    fputs IniFile "[RBBS]"
  327.    fputs IniFile "GraphicsOn=0"
  328.    fputs IniFile "MailDoorType=Mail Manager"
  329.    fputs IniFile "NamePrompt=first name"
  330.    fputs IniFile "PWordPrompt=Password"
  331.    fputs IniFile "UserResp1=n"
  332.    fputs IniFile "UserPrompt1=Review new files"
  333.    fputs IniFile "ScanPrompt=Check"
  334.    fputs IniFile "ViewPrompt=new bulletins"
  335.    fputs IniFile "MorePrompt=More"
  336.    fputs IniFile "FilePrompt=FILE Command"
  337.    fputs IniFile "ContinuePrompt=Continue"
  338.    fputs IniFile "CommandPrompt=Main Command"
  339.    fputs IniFile "DLPrompt=for transfer"
  340.    fputs IniFile "DLUnavPrompt=[ENTER] quits"
  341.    fputs IniFile "ULPrompt=for transfer"
  342.    fputs IniFile "ULDescPrompt=+----+|"
  343.    fputs IniFile ""
  344.    fputs IniFile "[KingMail]"
  345.    fputs Inifile "MailDoor=KM"
  346.    fputs IniFile "MailPrompt=KingMail Command"
  347.    fputs IniFile "ReceiveQWKPrompt=When Done"
  348.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  349.    fputs IniFile "MailULPrompt=Aborts Transfer"
  350.    fputs IniFile ""
  351.    fputs IniFile "[QMail]"
  352.    fputs IniFile "MailDoor=QM"
  353.    fputs IniFile "MailPrompt=QMail Command"
  354.    fputs IniFile "ReceiveQWKPrompt=these messages"
  355.    fputs IniFile "MailDLPrompt=Prepare to download"
  356.    fputs IniFile "MailULPrompt=Prepare to upload"
  357.    fputs IniFile ""
  358.    fputs IniFile "[MarkMail]"
  359.    fputs Inifile "MailDoor=MM"
  360.    fputs IniFile "MailPrompt=MarkMail Command"
  361.    fputs IniFile "ReceiveQWKPrompt=When Done"
  362.    fputs IniFile "MailDLPrompt=Aborts Transfer"
  363.    fputs IniFile "MailULPrompt=Aborts Transfer"
  364.    fputs IniFile ""
  365.    fputs IniFile "[RoseMail]"
  366.    fputs IniFile "MailDoor=RM"
  367.    fputs IniFile "MailPrompt=RoseMail Command"
  368.    fputs IniFile "ReceiveQWKPrompt=this Packet"
  369.    fputs IniFile "MailDLPrompt=Prepare to download"
  370.    fputs IniFile "MailULPrompt=Prepare to upload"
  371.    fputs IniFile ""
  372.    fputs IniFile "[Cam-Mail]"
  373.    fputs IniFile "MailDoor=CM"
  374.    fputs IniFile "MailPrompt=Cam-Mail Command"
  375.    fputs IniFile "ReceiveQWKPrompt=these messages"
  376.    fputs IniFile "MailDLPrompt=Prepare to upload"
  377.    fputs IniFile "MailULPrompt=Start your transfer"
  378.    fputs IniFile ""
  379.    fputs IniFile "[TomCat]"
  380.    fputs IniFile "MailDoor=T"
  381.    fputs IniFile "MsgMenuPrompt=MESSAGE MENU"
  382.    fputs IniFile "MailPrompt=TOMCAT MENU"
  383.    fputs IniFile "ReceiveQWKPrompt=when done"
  384.    fputs IniFile "MailDLPrompt=Start your"
  385.    fputs IniFile "MailULPrompt=Start your"
  386.    fputs IniFile ""
  387.    fputs IniFile "[Auntie Mail]"
  388.    fputs IniFile "MailDoor="
  389.    fputs IniFile "MailPrompt="
  390.    fputs IniFile "ReceiveQWKPrompt="
  391.    fputs IniFile "MailDLPrompt=Ctrl+X"
  392.    fputs IniFile "MailULPrompt=Ctrl+X"
  393.    fputs IniFile ""
  394.    fputs IniFile "[Mail Manager]"
  395.    fputs IniFile "MailDoor=d;mail"
  396.    fputs IniFile "MailPrompt=Your choice"
  397.    fputs IniFile "ReceiveQWKPrompt=this packet"
  398.    fputs IniFile "MailDLPrompt=Ready to send"
  399.    fputs IniFile "MailULPrompt=Ready to receive"
  400.    fclose IniFile
  401.    MailRun = MailRunIni
  402.  
  403.     if isfile OldIni
  404.         ;if there was a previous version of MailRun installed,
  405.         ;read the default values from the old file.
  406.         
  407.         ;don't offer the Aspect directory as a default for MailRunDir
  408.         profilerd OldIni "MailRun" "MailRunDir" MailRunDir
  409.         temp = makefullname(MailRunDir, "*")
  410.         fetch aspect scriptpath AspectDir
  411.         addfilename AspectDir "*"
  412.         if strcmpi temp AspectDir
  413.             MailRunDir = makefullname($PWTASKPATH, "mailrun")
  414.         endif
  415.  
  416.         profilerd OldIni "MailRun" "MailRun" MailRun
  417.         profilerd OldIni "MailRun" "DownloadDir" DownloadDir
  418.         profilerd OldIni "MailRun" "UploadDir" UploadDir
  419.         profilerd OldIni "MailRun" "MailDir" MailDir
  420.         profilerd OldIni "MailRun" "ReplyDir" ReplyDir
  421.         profilerd OldIni "MailRun" "DialAttempts" DialAttempts
  422.         profilerd OldIni "MailRun" "DialTimeout" DialTimeout
  423.         profilerd OldIni "MailRun" "DialPause" DialPause
  424.         profilerd OldIni "MailRun" "IdleTimeout" IdleTimeout
  425.         profilerd OldIni "MailRun" "SavePackets" SavePackets
  426.         profilerd OldIni "MailRun" "LogRun" LogRun
  427.         profilerd OldIni "MailRun" "AppendLog" AppendLog
  428.         profilerd OldIni "MailRun" "AnsiInLog" AnsiInLog
  429.         profilerd OldIni "MailRun" "NewfileFilter" NewfileFilter
  430.         profilerd OldIni "MailRun" "Archiver" Archiver
  431.         profilerd OldIni "MailRun" "QWKReader" QWKReader
  432.         profilerd OldIni "MailRun" "LogViewer" LogViewer
  433.     else
  434.        ;otherwise, suggest default values based on current system settings
  435.     
  436.        fetch dialdir maxdial StateMaxDial
  437.        fetch dialdir waitcnct StateWaitCnct
  438.        fetch dialdir callpause StateCallPause
  439.        fetch dnldpath StateDLPath
  440.        fetch upldpath StateULPath
  441.         MailRun = "mailrun.mrn"
  442.        MailRunDir = makefullname($PWTASKPATH, "mailrun")
  443.        DownloadDir = StateDLPath
  444.        UploadDir = StateULPath
  445.        MailDir = StateDLPath
  446.        ReplyDir = StateULPath
  447.        itoa StateMaxDial DialAttempts
  448.        itoa StateWaitCnct DialTimeout
  449.        itoa StateCallPause DialPause
  450.        IdleTimeout = "120"
  451.        SavePackets = "3"
  452.        LogRun = 1
  453.        AppendLog = 0
  454.        AnsiInLog = 0
  455.        NewfileFilter = 0
  456.     endif
  457.  
  458.     if Version >= 2.00
  459.         getbbstypes()
  460.     endif
  461.    MailRunList = "MAILRUN.INI"
  462.    MailRunTrunc = "MAILRUN.INI"
  463. endproc
  464.  
  465.  
  466. #comment
  467. *********************************************************************
  468. * GETBBSTYPES()
  469. * Called by makeini()
  470. * Adds any user created prompt sets from a previous version
  471. * of MailRun to MAILRUN.INI.
  472. *********************************************************************
  473. #endcomment
  474.  
  475. proc getbbstypes
  476. string BBSType_X, BBSType, MailDoor_X, MailDoorType, temp
  477. integer i, j
  478.     i = 1
  479.     j = 6
  480.     strfmt BBSType_X "BBSType_%d" i
  481.     profilerd OldIni "BBSTypes" BBSType_X BBSType
  482.     while not NULLSTR BBSType
  483.         switch BBSType
  484.             case "PCBoard 14.5"
  485.             case "WildCat! 3.5"
  486.             case "WildCat! 3.6"
  487.             case "Auntie"
  488.             case "RBBS"
  489.             endcase
  490.             default
  491.                 strfmt BBSType_X "BBSType_%d" j
  492.                 j++
  493.                 profilewr MailRunIni "BBSTypes" BBSType_X BBSType
  494.                 profilerd OldIni BBSType "MailDoorType" temp
  495.                 profilewr MailRunIni BBSType "MailDoorType" temp
  496.                 profilerd OldIni BBSType "LangPrompt" temp
  497.                 profilewr MailRunIni BBSType "LangPrompt" temp
  498.                 profilerd OldIni BBSType "GraphicsPrompt" temp
  499.                 profilewr MailRunIni BBSType "GraphicsPrompt" temp
  500.                 profilerd OldIni BBSType "NamePrompt" temp
  501.                 profilewr MailRunIni BBSType "NamePrompt" temp
  502.                 profilerd OldIni BBSType "PWordPrompt" temp
  503.                 profilewr MailRunIni BBSType "PWordPrompt" temp
  504.                 profilerd OldIni BBSType "Confirm1Prompt" temp
  505.                 profilewr MailRunIni BBSType "UserPrompt1" temp
  506.                 profilerd OldIni BBSType "Confirm2Prompt" temp
  507.                 profilewr MailRunIni BBSType "UserPrompt2" temp
  508.                 profilerd OldIni BBSType "ViewPrompt" temp
  509.                 profilewr MailRunIni BBSType "ViewPrompt" temp
  510.                 profilerd OldIni BBSType "ScanPrompt" temp
  511.                 profilewr MailRunIni BBSType "ScanPrompt" temp
  512.                 profilerd OldIni BBSType "FilePrompt" temp
  513.                 profilewr MailRunIni BBSType "FilePrompt" temp
  514.                 profilerd OldIni BBSType "MorePrompt" temp
  515.                 profilewr MailRunIni BBSType "MorePrompt" temp
  516.                 profilerd OldIni BBSType "ContinuePrompt" temp
  517.                 profilewr MailRunIni BBSType "ContinuePrompt" temp
  518.                 profilerd OldIni BBSType "CommandPrompt" temp
  519.                 profilewr MailRunIni BBSType "CommandPrompt" temp
  520.                 profilerd OldIni BBSType "DLPrompt" temp
  521.                 profilewr MailRunIni BBSType "DLPrompt" temp
  522.                 profilerd OldIni BBSType "DLUnavPrompt" temp
  523.                 profilewr MailRunIni BBSType "DLUnavPrompt" temp
  524.                 profilerd OldIni BBSType "ULPrompt" temp
  525.                 profilewr MailRunIni BBSType "ULPrompt" temp
  526.                 profilerd OldIni BBSType "ULDescPrompt" temp
  527.                 profilewr MailRunIni BBSType "ULDescPrompt" temp
  528.             endcase
  529.         endswitch
  530.         i++
  531.         strfmt BBSType_X "BBSType_%d" i
  532.         profilerd OldIni "BBSTypes" BBSType_X BBSType
  533.     endwhile
  534.     i = 1
  535.     j = 9
  536.     strfmt MailDoor_X "MailDoor_%d" i
  537.     profilerd OldIni "MailDoors" MailDoor_X MailDoorType
  538.     while not NULLSTR MailDoorType
  539.         switch MailDoorType
  540.             case "QMail"
  541.             case "MarkMail"
  542.             case "Cam-Mail"
  543.             case "RoseMail"
  544.             case "KingMail"
  545.             case "TomCat"
  546.             case "Auntie Mail"
  547.             case "Mail Manager"
  548.             endcase
  549.             default
  550.                 strfmt MailDoor_X "MailDoor_%d" j
  551.                 j++
  552.                 profilewr MailRunIni "MailDoors" MailDoor_X MailDoorType
  553.                 profilerd OldIni MailDoorType "MailDoor" temp
  554.                 profilewr MailRunIni MailDoorType "MailDoor" temp
  555.                 profilerd OldIni MailDoorType "MailPrompt" temp
  556.                 profilewr MailRunIni MailDoorType "MailPrompt" temp
  557.                 profilerd OldIni MailDoorType "ReceiveQWKPrompt" temp
  558.                 profilewr MailRunIni MailDoorType "ReceiveQWKPrompt" temp
  559.                 profilerd OldIni MailDoorType "MailDLPrompt" temp
  560.                 profilewr MailRunIni MailDoorType "MailDLPrompt" temp
  561.                 profilerd OldIni MailDoorType "MailULPrompt" temp
  562.                 profilewr MailRunIni MailDoorType "MailULPrompt" temp
  563.                 profilerd OldIni MailDoorType "MsgMenuPrompt" temp
  564.                 profilewr MailRunIni MailDoorType "MsgMenuPrompt" temp
  565.                 profilerd OldIni MailDoorType "QWKArchiver" temp
  566.                 profilewr MailRunIni MailDoorType "QWKArchiver" temp
  567.                 profilerd OldIni MailDoorType "MailXferProt" temp
  568.                 profilewr MailRunIni MailDoorType "MailXferProt" temp
  569.             endcase
  570.         endswitch
  571.         i++
  572.         strfmt MailDoor_X "MailDoor_%d" i
  573.         profilerd OldIni "MailDoors" MailDoor_X MailDoorType
  574.     endwhile
  575. endproc    
  576.  
  577.  
  578. #comment
  579. *********************************************************************
  580. * CHANGESETTINGS()
  581. * Called by main()
  582. * Calls checkdir(), settingsbox()
  583. * Allows the user to change the defaults in MAILRUN.INI.
  584. *********************************************************************
  585. #endcomment
  586.  
  587. proc changesettings
  588. string LastMRunDir, LastMailDir, LastReplyDir
  589. string LastDLDir, LastULDir
  590. string SaveMsg = "You have not saved your MailRun settings.  \
  591. Select `"OK`" to return, `"Cancel`" to abort MailRun."
  592. integer dialogstatus, savestatus
  593. integer Response
  594.    ;Save old values in case of error in directory creation
  595.    LastMRunDir = MailRunDir
  596.    LastMailDir = MailDir
  597.    LastReplyDir = ReplyDir
  598.    LastDLDir = DownloadDir
  599.    LastULDir = UploadDir
  600.    settingsbox()
  601.    disable CTRL 170
  602.    savestatus = 1
  603.    while 1
  604.       dialogstatus = $DIALOG
  605.       switch dialogstatus
  606.          case 10
  607.             ;User selected "Save"
  608.             ;if the directories chosen in settingsbox()
  609.             ;don't exist, create them
  610.                 if checkdir(&MailRunDir, LastMRunDir) && \
  611.                     checkdir(&MailDir, LastMailDir) && \
  612.                     checkdir(&ReplyDir, LastReplyDir) && \
  613.                     checkdir(&DownloadDir, LastDLDir) && \
  614.                     checkdir(&UploadDir, LastULDir)
  615.                ;if all directories exist or were successfully created
  616.                ;write the settings to MAILRUN.INI
  617.                chdir MailRunDir
  618.                profilewr MailRunIni "MailRun" "MailRunDir" MailRunDir
  619.                profilewr MailRunIni "MailRun" "MailDir" MailDir
  620.                profilewr MailRunIni "MailRun" "ReplyDir" ReplyDir
  621.                profilewr MailRunIni "MailRun" "DownloadDir" DownloadDir
  622.                profilewr MailRunIni "MailRun" "UploadDir" UploadDir
  623.                profilewr MailRunIni "MailRun" "DialAttempts" DialAttempts
  624.                profilewr MailRunIni "MailRun" "DialTimeout" DialTimeout
  625.                profilewr MailRunIni "MailRun" "DialPause" DialPause
  626.                profilewr MailRunIni "MailRun" "IdleTimeout" IdleTimeout
  627.                profilewr MailRunIni "MailRun" "SavePackets" SavePackets
  628.                profilewr MailRunIni "MailRun" "LogRun" LogRun
  629.                profilewr MailRunIni "MailRun" "AppendLog" AppendLog
  630.                profilewr MailRunIni "MailRun" "AnsiInLog" AnsiInLog
  631.                profilewr MailRunIni "MailRun" "NewfileFilter" NewfileFilter
  632.                profilewr MailRunIni "MailRun" "Archiver" Archiver
  633.                profilewr MailRunIni "MailRun" "QWKReader" QWKReader
  634.                profilewr MailRunIni "MailRun" "LogViewer" LogViewer
  635.             else
  636.                updatedlg 128
  637.                loopwhile
  638.             endif
  639.             savestatus = 0
  640.          endcase
  641.          case 11
  642.             ;User selected "Done"
  643.             if savestatus == 0
  644.                ;if settings have been saved, return to processing
  645.                exitwhile
  646.             endif
  647.             if savestatus == 1
  648.                ;if settings have not been saved, display a warning
  649.                sdlgmsgbox "MailRun Message" SaveMsg EXCLAMATION \
  650.                   OKCANCEL Response 1
  651.                switch Response
  652.                   case 1
  653.                      ;User selected "OK" to continue
  654.                      loopwhile
  655.                   endcase
  656.                   case 2
  657.                      ;User selected "Cancel" to abort
  658.                      delfile MailRunIni
  659.                      halt
  660.                   endcase
  661.                endswitch
  662.             endif
  663.          endcase
  664.          case 70
  665.             ;User selected the "Capture mailrun..." checkbox
  666.             if LogRun == 0
  667.                disable CTRL 71
  668.                disable CTRL 72
  669.             else
  670.                enable CTRL 71
  671.                enable CTRL 72
  672.             endif
  673.             savestatus = 1
  674.             updatedlg 1
  675.          endcase
  676.          case 230
  677.          case 231
  678.          case 232
  679.          case 233
  680.          case 234
  681.          case 235
  682.          case 236
  683.          case 237
  684.          case 238
  685.          case 239
  686.          case 240
  687.          case 241
  688.          case 242
  689.          case 71
  690.          case 72
  691.          case 73
  692.             savestatus = 1
  693.          endcase
  694.       endswitch
  695.    endwhile
  696. endproc
  697.  
  698.  
  699. #comment
  700. *********************************************************************
  701. * CHECKDIR()
  702. * Called by main(), changesettings()
  703. * Creates a directory.  Returns 1 if directory was successfully
  704. * created or already existed; returns 0 if an error ocurred in
  705. * creation.
  706. *********************************************************************
  707. #endcomment
  708.  
  709. func checkdir : integer
  710. strparm NewDir, OldDir
  711.     chdir NewDir
  712.     if FAILURE
  713.         mkdir NewDir
  714.         if FAILURE
  715.             usermsg "Unable to create directory %s" NewDir
  716.             NewDir = OldDir
  717.             return 0
  718.         endif
  719.     endif
  720.     return 1
  721. endfunc
  722.  
  723.  
  724. #comment
  725. *********************************************************************
  726. * MOVEDIR()
  727. * Called by main()
  728. * Calls makefullname(), movefiles()
  729. * Moves MailRun source files to the MailRun directory.
  730. *********************************************************************
  731. #endcomment
  732.  
  733. proc movedir
  734. string aspectpath, temp1, temp2
  735.    temp1 = makefullname(MailRunDir,"*") 
  736.    fetch aspect defaultpath aspectpath
  737.    temp2 = makefullname(aspectpath, "*")
  738.    if not strcmpi temp1 temp2
  739.         movefiles(aspectpath, MailRunDir, "MRUN211?.WA?")
  740.         movefiles(aspectpath, MailRunDir, "MRUN211.H")
  741.         movefiles(aspectpath, MailRunDir, "NEWFILES.WA?")
  742.         movefiles(aspectpath, MailRunDir, "TERMINAL.WA?")
  743.         movefiles(aspectpath, MailRunDir, "MRUNICON.DLL")
  744.         movefiles(aspectpath, MailRunDir, "MAILRUN.WRI")
  745.       statmsg ""
  746.    endif
  747. endproc
  748.  
  749.  
  750. #comment
  751. *********************************************************************
  752. * MOVEFILES()
  753. * Called by movedir()
  754. * Calls makefullname()
  755. * Moves all files matching a filespec from their current
  756. * location to a new directory.
  757. *********************************************************************
  758. #endcomment
  759.  
  760. proc movefiles
  761. strparm OldDir, NewDir, Spec
  762. string OldFile, NewFile, OldSpec
  763.     OldSpec = makefullname(OldDir, Spec)
  764.     findfirst OldSpec
  765.     while FOUND
  766.         if not strcmpi $FILENAME "MRUN211.WAS"
  767.             if not strcmpi $FILENAME "MRUN211.WAX"
  768.                statmsg "Moving %s" $FILENAME
  769.                 OldFile = makefullname(OldDir, $FILENAME)
  770.                 NewFile = makefullname(NewDir, $FILENAME)
  771.                 copyfile OldFile NewFile
  772.                 delfile OldFile
  773.             endif
  774.         endif
  775.         findnext
  776.     endwhile
  777. endproc
  778.  
  779.  
  780. #comment
  781. *********************************************************************
  782. * UPDATEMRN()
  783. * Called by main()
  784. * Calls makefullname(), checkfile()
  785. * Updates existing *.MRN files to MailRun 2.1 format.
  786. *********************************************************************
  787. #endcomment
  788.  
  789. proc updatemrn
  790. string filespec, mrnfile, BBSi, XferProt, BBS_X, BBSType
  791. string MailDoor, MailPrompt
  792. integer i
  793.    filespec = makefullname(MailRunDir, "*.MRN")
  794.    findfirst filespec
  795.    while FOUND
  796.       statmsg "Updating Mailrun %s" $FILENAME
  797.          mrnfile = makefullname(MailRunDir, $FILENAME)
  798.          profilewr mrnfile "MailRun" "DLPurgeLimit" 0
  799.       profilewr mrnfile "MailRun" "GoWait" 1
  800.          profilewr mrnfile "MailRun" "PostRun" 1
  801.          profilewr mrnfile "MailRun" "RingInterrupt" 1
  802.       i = 1
  803.          strfmt BBS_X "BBS_%d" i
  804.          profilerd mrnfile "MailRun" BBS_X BBSi
  805.        while not NULLSTR BBSi
  806.            profilerd mrnfile BBSi "BBSType" BBSType
  807.                 if strcmpi BBSType "WildCat! 3.5"
  808.                     profilewr mrnfile BBSi "BBSType" "WildCat! 3.6"
  809.                profilewr mrnfile BBSi "MsgMenuPrompt" "MESSAGE MENU"
  810.              endif
  811.            if checkfile(OldIni) && Version != 2.00
  812.               profilewr mrnfile BBSi "BBSType" "PCBoard 14.5"
  813.                  profilewr mrnfile BBSi "ViewPrompt" "View"
  814.                profilerd mrnfile BBSi "XferProt" XferProt
  815.                 profilewr mrnfile BBSi "MailXferProt" XferProt
  816.                    profilerd mrnfile BBSi "MailDoor" MailDoor
  817.                    strfmt MailDoor "door;%s" MailDoor
  818.                    profilewr mrnfile BBSi "MailDoor" MailDoor
  819.                 profilerd mrnfile BBSi "MailPrompt" MailPrompt
  820.                 if strfind MailPrompt "QMail"
  821.                     profilewr mrnfile BBSi "MailDoorType" "QMail"
  822.                 elseif strfind MailPrompt "MarkMail"
  823.                     profilewr mrnfile BBSi "MailDoorType" "MarkMail"
  824.                 elseif strfind MailPrompt "Cam-Mail"
  825.                     profilewr mrnfile BBSi "MailDoorType" "Cam-Mail"
  826.                 elseif strfind MailPrompt "RoseMail"
  827.                     profilewr mrnfile BBSi "MailDoorType" "RoseMail"
  828.                 elseif strfind MailPrompt "KingMail"
  829.                     profilewr mrnfile BBSi "MailDoorType" "KingMail"
  830.                 endif
  831.               endif
  832.             i++
  833.             strfmt BBS_X "BBS_%d" i
  834.          profilerd mrnfile "MailRun" BBS_X BBSi
  835.          endwhile
  836.          findnext
  837.       endwhile
  838.       statmsg ""
  839. endproc
  840.       
  841.  
  842. #comment
  843. *********************************************************************
  844. * GETTEMPDIR()
  845. * Called by main()
  846. * Assigns the name of the MailRun temporary directory to
  847. * TempDir.
  848. *********************************************************************
  849. #endcomment
  850.  
  851. proc gettempdir
  852. string env
  853.    getenv "TEMP" env
  854.    if NULLSTR env
  855.       TempDir = $PWTASKPATH
  856.    else
  857.       TempDir = env
  858.    endif
  859.    addfilename TempDir "MRUNTEMP"
  860. endproc
  861.  
  862.  
  863. #comment
  864. *********************************************************************
  865. * CHECKFILE()
  866. * Called by main()
  867. * Checks for a file's existence.  Returns 1 if the file is
  868. * found, 0 if not found.
  869. *********************************************************************
  870. #endcomment
  871.  
  872. func checkfile : integer
  873. strparm FileNom
  874.    if isfile FileNom
  875.       return 1
  876.    else
  877.       return 0
  878.    endif
  879. endfunc
  880.  
  881.  
  882. #comment
  883. *********************************************************************
  884. * MAKEFULLNAME()
  885. * Called by various.
  886. * Appends a filename to a directory name.
  887. *********************************************************************
  888. #endcomment
  889.  
  890. func makefullname : string
  891. strparm Directory, FileNamen
  892. string FullName
  893.    FullName = Directory 
  894.    addfilename FullName FileNamen
  895.    return FullName
  896. endfunc
  897.  
  898.  
  899. #comment
  900. *********************************************************************
  901. * WELCOMEBOX()
  902. * Called by makeini()
  903. * Displays a dialog box to welcome first time users.
  904. *********************************************************************
  905. #endcomment
  906.  
  907. proc welcomebox
  908. HelpPage = 1
  909. dialogbox 80 57 198 125 15 "MailRun" HELPID HelpPage
  910.    text  10 11 178 8 center "Welcome to MailRun 2.1!"
  911.    text  21 26 156 63 center "Before you begin, you will need to \
  912. configure some basic system settings.  Default settings for MailRun \
  913. are stored in the file MAILRUN.INI, which may be manually edited.`r`n`r`n\
  914. Press F1 for Help."
  915.    pushbutton 49 95 40 14 "OK" normal
  916.    pushbutton 104 95 40 14 "Cancel" cancel
  917. enddialog
  918. endproc
  919.  
  920.  
  921. #comment
  922. *********************************************************************
  923. * SETTINGSBOX()
  924. * Called by changesettings()
  925. * Displays the MailRun Settings dialog box.
  926. *********************************************************************
  927. #endcomment
  928.  
  929. proc settingsbox
  930. HelpPage = 13
  931. dialogbox 15 36 340 222 15 "MailRun Settings" HELPID HelpPage
  932.    groupbox 10 28 200 96 "Directories" shadow
  933.    text  16 42 71 8 right "MailRun Directory:"
  934.    text  16 58 71 8 right "Mail Directory:"
  935.    text  16 74 71 8 right "Reply Directory:"
  936.    text  16 90 71 8 right "Download Directory:"
  937.    text  16 106 71 8 right "Upload Directory:"
  938.    editbox 91 56 110 12 MailDir
  939.    editbox 91 72 110 12 ReplyDir
  940.    editbox 91 88 110 12 DownloadDir
  941.    editbox 91 104 110 12 UploadDir
  942.    groupbox 224 28 102 96 "Parameters" shadow
  943.    text  234 42 62 8 right "Dial Attempts:"
  944.    text  234 58 62 8 right "Dial Timeout:"
  945.    text  234 74 62 8 right "Dial Pause:"
  946.    text  234 90 62 8 right "Idle Timeout:"
  947.    text  234 106 62 8 right "Packets to Save:"
  948.    editbox 300 40 16 12 DialAttempts
  949.    editbox 300 56 16 12 DialTimeout
  950.    editbox 300 72 16 12 DialPause
  951.    editbox 300 88 16 12 IdleTimeOut
  952.    editbox 300 104 16 12 SavePackets
  953.    groupbox 10 132 124 59 "Logging" shadow
  954.    checkbox 18 144 112 12 "Capture mailrun to log file" LogRun
  955.    checkbox 18 158 112 12 "Append to existing log file" AppendLog
  956.    checkbox 18 172 112 12 "Capture ANSI codes in log file" AnsiInLog
  957.    checkbox 18 200 134 12 "Filter duplicates from d/l database" NewfileFilter
  958.    groupbox 144 132 184 59 "Utilities" shadow
  959.    text  145 146 65 8 right "Archive Utility:"
  960.    text  145 160 65 8 right "QWK Mail Reader:"
  961.    text  145 174 65 8 right "Log File Viewer:"
  962.    editbox 214 144 107 12 Archiver
  963.    editbox 214 158 107 12 QWKReader
  964.    editbox 214 172 107 12 LogViewer
  965.    pushbutton 191 200 40 14 "&Save" normal default
  966.    pushbutton 252 200 40 14 "&Done" normal
  967.    text  100 11 52 8 right "Settings for:"
  968.    combobox 156 9 72 42 MailRunList MailRunTrunc sort
  969.    editbox 91 40 110 12 MailRunDir
  970. enddialog
  971. endproc
  972.  
  973.  
  974.  
  975.